<script setup lang="ts">
import {useRouter} from "vue-router";
import useUserStore from "@/store/mod/user.ts";
import { ArrowDown } from '@element-plus/icons-vue'
let userStore = useUserStore()
const $router = useRouter()
function goHome(){
  $router.push('/')
}

/**
 * 登录的方法
 */
function login(){
  userStore.visiable=!userStore.visiable
}
/**
 * 注销登录
 */
function loginOut(){
  userStore.loginOut()
  $router.push('/home')
}
/**
 * 跳转到某个页面
 */
function goPath(path:string){
  $router.push({
    path:path,
  })
}
</script>
<template>
<div class="top">
  <div class="content">
    <div class="left" @click="goHome">
      <img src="../../assets/images/logo.png" alt="">
      <p>尚医通&nbsp;预约挂号统一平台</p>
    </div>
    <div class="right">
      <p class="help">帮助中心</p>
      <p class="login" @click="login" v-if="!userStore.userInfo.name">登录/注册</p>
      <el-dropdown v-else>
          <span class="el-dropdown-link">
          {{userStore.userInfo.name}}
          <el-icon class="el-icon--right">
            <arrow-down />
          </el-icon>
          </span>
          <template #dropdown>
            <el-dropdown-menu>
              <el-dropdown-item @click="goPath('/user/certification')">实名认证</el-dropdown-item>
              <el-dropdown-item @click="goPath('/user/order')">挂号订单</el-dropdown-item>
              <el-dropdown-item @click="goPath('/user/patient')">就诊人管理</el-dropdown-item>
              <el-dropdown-item @click="loginOut">退出登录</el-dropdown-item>
            </el-dropdown-menu>
          </template>
      </el-dropdown>
    </div>
  </div>
</div>
</template>
<style scoped lang="scss">
.top{
  width: 100%;
  height: 70px;
  background: #ffffff;
  position: fixed;
  z-index: 999;
  top: 0;
  left: 0;
  right: 0;
}
.content{
  width: 1200px;
  margin: 0 auto;
  height: 70px;
  border-bottom:1px solid black;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  .left{
    cursor: pointer;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
      img{
        width: 50px;
        height: 50px;
        margin-right: 10px;
      }
      p{
        font-size: 20px;
        color:#55a6fe;
      }
  }
  .right{
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    font-size: 14px;
    .help{
      margin-right: 10px;
    }
  }
}
</style>